var Api = require('../../utils/api.js');
var app = getApp();
var imageUtil = require('../../utils/util.js');
var WxParse = require('../../wxParse/wxParse.js');
Page({
  data: {
    order: '',
  },
  onLoad: function (options) {
    var that = this;
    that.setData({
      id: options.id,
    });
    var url = Api.HOST + 'wechat.php?s=Home/details';
    var data = {};
    data.id = this.data.id;
    Api.fetchPost(url, data, (err, res) => {
      that.setData({
        order: res.order,
      });
    });
  },
  onShareAppMessage: function (res) {
    console.log(res)
    if (res.from === 'button') {
      // 来自页面内转发按钮
      return {
        title: '大数据征信查询',
        path: '/pages/index/index',
        success: function (res) {
          // 转发成功
          var that = this;

          app.getUserInfo(function (userInfo) {
            var user = wx.getStorageSync('user');
            var url = Api.HOST + 'wechat.php?s=Home/share';

            var data = {};
            data.openid = user.openid;

            Api.fetchPost(url, data, (err, res) => {
              that.setData({

              });
            });
          })

        },
        fail: function (res) {
          // 转发失败
        }
      }
    } else {
      return {
        title: '大数据征信查询',
        path: '/pages/index/index',
        success: function (res) {
          // 转发成功
          var that = this;

          app.getUserInfo(function (userInfo) {
            var user = wx.getStorageSync('user');
            var url = Api.HOST + 'wechat.php?s=Home/share';

            var data = {};
            data.openid = user.openid;

            Api.fetchPost(url, data, (err, res) => {
              that.setData({

              });
            });
          })

        },
        fail: function (res) {
          // 转发失败
        }
      }
    }
  },
})

